package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.QueryConpouBase;
import com.scsj.supermarket.bean.MineCouponBean;
import com.scsj.supermarket.model.QueryMineConpouModel;

import org.json.JSONObject;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/6/25.
 * 我的优惠券
 */

public class MineConpouPresenter extends BasePresenter implements QueryConpouBase.IPresenter{


    private QueryConpouBase.IView mView;
    private QueryConpouBase.IModel mModel;

    public MineConpouPresenter(QueryConpouBase.IView mView) {
        this.mView = mView;
        mModel = new QueryMineConpouModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {
        addSubscription(mModel.getData(requestBody, new ResponseCallback<MineCouponBean>() {
            @Override
            public void onSuccess(MineCouponBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));
    }
}
